package com.business;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * Hello world!
 * 业务
 * 排序druid的默认配置,使用自己的配置
 */
@EnableFeignClients
@Slf4j
@EnableAsync
@MapperScan("com.business.dao")
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
public class CloudBusinessApplication {

    static final String path = "/src/resources/config/log4j.properties";

    public static void main( String[] args ) {
        /**
         * springboot 和 nacos-config均继承了LogBack,在运行时报错但不影响程序启动,
         * 错误原因
         * 错误原因在于nacos引入的nacsos-client.jar内含有默认的nacos-logback.xml/nacos-log4j2.xml，其中nacos-logback.xml中contextName属性为nacos
         * 该属性与自定义的logback.xml不一致导致冲突
         *
         * 解决:在启动类中关闭其中一个 logback 的配置(一般关闭外部框架的)
         * 处理方法
         * 1、修改自定义的logback.xml的contextName属性与nacsos-client.jar的配置保持一致
         * 2、启动命令添加配置 -Dnacos.logging.default.config.enabled=false，该配置在nacos加载时，读取系统配置
         * 3、启动类中添加 System.setProperty("nacos.logging.default.config.enabled","false");
         */
        System.setProperty("nacos.logging.default.config.enabled","false");

        //PropertyConfigurator.configure(path);

        SpringApplication.run(CloudBusinessApplication.class,args);
        log.info("CloudBusinessActivity 启动成功...");
    }
}
